﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CcrSpaces.Core;
using kk.components.contracts;
using kk.components.contracts.ServiceContract;
using kk.messages.contracts.DataModel;
using kk.messages.contracts.ViewModel;
using XcoAppSpaces.Core;

namespace kk.kinokasseservicestub
{
    public class KinokasseServiceStubInSpace : IKinokasseServiceStub
    {
        private XcoAppSpace space;
        
        public void Configure(string configString)
        {
            space = new XcoAppSpace(configString);

            var worker = new KinokasseServiceWorker();
            worker.OnBelegungsplanZuVorstellung += req => this.OnBelegungsplanZuVorstellung(req);
            worker.OnReservierungsanfrage += req => this.OnReservierungsanfrage(req);

            space.RunWorker<PKinokasseServiceStub>(worker, PKinokasseServiceStub.SERVICE_NAME);
        }


        public event Action<Request<Vorstellung, Belegungsplan>> OnBelegungsplanZuVorstellung;
        public event Action<Request<Reservierungsanfrage, Reservierungsbestätigung>> OnReservierungsanfrage;


        public void Dispose()
        {
            if (space != null) space.Dispose();
        }
    }
}
